package com.blackfish.device;

import java.util.List;

import com.blackfish.common.model.Device;
import com.blackfish.module.ModuleInterceptor;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Record;

public class DeviceController extends Controller{
	static DeviceService deviceService = new DeviceService();
	public void index(){
		render("index.html");
	}
	
	public void table(){
		List<Record> record = deviceService.getAllJson();
		renderJson(record);
	}
	
	public void add(){
		String name = getAttr("name");
		if(!deviceService.saveDevice(name)){
			renderText("Error");
		}
		renderText("OK");
	}
}
